package cn.anxingongyou.anxin.controller;

import cn.anxingongyou.anxin.service.CountService;
import cn.anxingongyou.anxin.utils.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class CountController {

    private final CountService countService;
    @Autowired
    public CountController(CountService countService) {
        this.countService = countService;
    }

    @ApiOperation("获取统计数据")
    @ApiResponses({
            @ApiResponse(code = 200,message = "获取成功"),
            @ApiResponse(code = 500,message = "获取失败")
    })
    @RequestMapping(value = "/count/info",method = RequestMethod.GET)
    public Map countInfo(){
        Map<String, Object> result = countService.countInfo();
        return Result.<Map<String, Object>>instance(200,"统计结果",result).toJsonMap();
    }
}
